package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.UUID;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

import myz.date.gui.CalendarPad;
import myz.date.gui.NumberLenghtLimitedDmt;

import org.apache.commons.io.FilenameUtils;

import db.domain.SystemPictur;
import db.domain.SystemPictur;
import db.sqldao.SystemPicturSqlDao;

/**
 * 系统图片组信息界面
 * 
 * @author 冀鲁
 * @date 2011-06-30
 * @version 1.0.0.0
 * 
 */
@SuppressWarnings("serial")
public class ShowPicturForm extends JDialog {
	private JPanel jp;
	private JLabel lblPicture;// 登陆皮肤

	public ShowPicturForm(SystemPictur systemPictur, double wx, double wy) {
		int width = 200, height = 260;
		String title = null;
		this.setTitle(systemPictur.getName());
		this.setLayout(null);
		jp = new JPanel(null);// 使用坐标布局
		jp.setBounds(0, 0, width, height);
		this.add(jp);

		/* 系统图片 */
		lblPicture = new JLabel(
				"<html>		未<br>		上<br>		传<br>		皮<br>		肤<br></html>");
		// lblPicture[i].setBorder(new LineBorder(Color.blue, 5, true));
		lblPicture.setBounds(0, 0, width, height);
		jp.add(lblPicture);

		// this.setModal(true);// 窗口独占模式（JDialog独有）
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		// 匿名内部类
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent arg0) {
				closeWindow();
			}
		});

		this.setLocation((int) wx, (int) wy);
		this.setSize(width, height);
		this.setResizable(false);
		displaysystemPictur(systemPictur);

		this.setVisible(true);
	}

	protected void closeWindow() {
		// 关闭窗口
		this.dispose();// 释放本窗口资源
	}

	/**
	 * 将皮肤信息显示到窗口的组件上
	 * 
	 * @param systemPictur
	 */
	private void displaysystemPictur(SystemPictur systemPictur) {

		// 显示个人照片
		String path;
		path = systemPictur.getPictur1();

		// 显示每组各个图片

		if (path != null) {
			File f = new File(path);
			if (f.exists()) {
				ImageIcon icon = new ImageIcon(path);
				// 图片自适应大小
				icon.setImage(icon.getImage().getScaledInstance(
						lblPicture.getWidth(), lblPicture.getHeight(),
						Image.SCALE_DEFAULT));
				lblPicture.setIcon(icon);
				lblPicture.updateUI();
			}

		}

	}

}
